<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title>添加管理员</title>
<link rel="stylesheet" href="../../css/pintuer.css">
<link rel="stylesheet" href="../../css/admin.css">
<script src="../../js/jquery.js"></script>
<script src="../../js/pintuer.js"></script>
<script src="../../js/md5.js"></script>
<script src="../../js/tools.js"></script>
</head>
<body>
	<div class="panel admin-panel">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>增加内容</strong>
		</div>
		<div class="body-content">
			<form method="post" class="form-x" action="">
				<div class="form-group">
					<div class="label">
						<label>登录名：</label>
					</div>
					<div class="field">
						<input type="text" id="productTypeName" class="input w50" maxlength="16"
							value="" name="productTypeName" data-validate="required:请输入分类名称" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>状态：</label>
					</div>
					<div class="field">
						<select class="input w50" id="status">
							<option value="1">上架</option>
							<option value="2">下架</option>
							<option value="3">删除</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button class="button bg-main icon-check-square-o" id="submit"
							type="button">提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
<script type="text/javascript">
$(function() {
	var id = getUrlParam('id');
	//查询管理员信息
	$.ajax({
			type : "POST",
			url : host_url + "product-type/getProductTypeById",
			xhrFields : {
				withCredentials : true
			},
			data : {
				"id": id
			},
			success : function(data) {
				$("#productTypeName").val(data.data.name);
				$("#status").val(data.data.status);
			}
	});
	
	//提交更新数据
	$("#submit").click(function() {
		var name = $("#productTypeName").val();
		var status = $("#status").val();
		if (name == null || name == '') {
			alert("分类名不能为空！");
			return;
		}
		$.ajax({
			type : "POST",
			url : host_url + "product-type/updateProductTypeById",
			data : {
				id : id,
				loginName : name,
				status : status
			},
			success : function(data) {
				if (data.code == 0) {
					location.href = "./list.html";
				} else {
					alert(data.msg);
				}
			}
			});
		});
	})
</script>
</html>